#include "../server/rpc_server.hpp"
void Add(const Json::Value& req,Json::Value& result)
{
    DLOG("开始运算");
    int num1 = req["num1"].asInt();
    DLOG("num1:%d",num1);
    int num2 = req["num2"].asInt();
    DLOG("num2:%d",num2);

    result = num1 + num2;
    std::cout<<result<<std::endl;
}
int main()
{
    std::unique_ptr<bitrpc::server::ServiceFactory> desc_factory(std::make_unique<bitrpc::server::ServiceFactory>());
    desc_factory->setMethodName("Add");
    desc_factory->setParamsDesc("num1",bitrpc::server::VType::INTEGRAL);
    desc_factory->setParamsDesc("num2",bitrpc::server::VType::INTEGRAL);
    desc_factory->returnType(bitrpc::server::VType::INTEGRAL);
    desc_factory->setCallback(Add);
    bitrpc::server::RpcServer server(bitrpc::Address("127.0.0.1",9090),true,bitrpc::Address("127.0.0.1",8080));
    server.registerMethod(desc_factory->build());
    server.start();
    return 0;
}